﻿create or replace function sum_array( numeric[] )
returns decimal
as $$
/*
||  Sum the values in an array. 
|| Make sure th array is in numeric format
||  
||  Example:
||  SELECT sum_array(array[1,2,3]::numeric[]);
*/
 select sum($1[i])
 from generate_series(
        array_lower($1,1),
        array_upper($1,1)
      ) g(i);
$$ language sql immutable;

